home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: ParentStack.C,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:55:16 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
- #include "BTREEPAGE.h"
- #include "ParentStack.h"
-
-
-
- //
- // Class : ParentStack
- // Method : Destructor
- // Description : Unfix every page in the stack. If the page is not leaf,
- // unlock it, too.
- //
- ParentStack::~ParentStack()
- {
- while (cnt-- > 0) {
- if ((GROUPLINK*)descPtr[cnt]) {
- BTREEPAGE* bp = descPtr[cnt];
- if (bp->IsNode())
- descPtr[cnt].UnfixUnlock();
- else
- descPtr[cnt].Unfix();
- }
- }
- }
-
-
-
- //
- // Class : ParentStack
- // Method : void DiscardTop()
- // Description : Pop the top entry int he stack and unfix it. If it is
- // not a leaf, unlock it as well.
- //
- void ParentStack::DiscardTop()
- {
- PageDesc pd = Pop();
- BTREEPAGE* bp = pd;
-
- if (bp) {
- if (bp->IsNode())
- pd.UnfixUnlock();
- else
- pd.Unfix();
- }
- }
-
-
-
- //
- // Class : ParentStack
- // Method : int ReadNPush(PID& const pid, LOCKMODE lockMode)
- // Description : Read page 'pid' with 'lockMode', and push it onto the stack.
- //
- int ParentStack::ReadNPush(const PID& pid, LOCKMODE lockMode)
- {
- PageDesc pd;
-
- if (pd.Read(bufGroup, pid, lockMode))
- return esmFAILURE;
-
- Push(pd);
-
- return esmNOERROR;
- }
-
-
-
-
-
-
- //
- // Class : ParentStack
- // Method : void Print()
- // Description : Prints the stack for debugging purposes
- //
- void ParentStack::Print()
- {
- printf("ParentStack: \n");
- for (int i = 0; i < cnt; i++) {
- BTREEPAGE* bt = descPtr[i];
- if (bt == 0) {
- printf("\tdescPtr[%d] is released\n", i);
- continue;
- }
- printf("\tdescPtr[%d] = page %d, level %d, freeSpace %d\n", i,
- bt->SelfID().page, bt->Level(),
- bt->FreeSpace());
- }
- }
-
-